﻿using LuDragon.Common.Constant;
using LuDragon.Data.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace LuDragon.Common.Utils
{
    /// <summary>
    /// 登录Session帮助类
    /// </summary>
    public static class LoginHelper
    {
        /// <summary>
        /// 保存登录信息Session
        /// </summary>
        /// <param name="name"></param>
        /// <param name="user"></param>
        public static void SaveLoginSession(object user)
        {
            HttpContext.Current.Session.Remove(SessionKey.USER_INFO);
            HttpContext.Current.Session.Add(SessionKey.USER_INFO, user);
        }
        /// <summary>
        /// 获取登录信息是Session
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static object GetLoginSession()
        {
            return HttpContext.Current.Session[SessionKey.USER_INFO];
        }
        /// <summary>
        /// 删除登录信息
        /// </summary>
        /// <param name="name"></param>
        public static void RemoveLoginSession()
        {
            HttpContext.Current.Session.Remove(SessionKey.USER_INFO);
        }
    }
}
